package com.right.health.app.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.right.health.app.R;
import com.right.health.app.app.App;
import com.right.health.app.bean.Banner;
import com.right.health.app.utils.GlideUtil;
import com.right.health.app.widget.banner.BaseIndicatorBanner;


public class HomeBannerView extends BaseIndicatorBanner<Banner, HomeBannerView> {

    public HomeBannerView(Context context) {
        this(context, null, 0);
    }

    public HomeBannerView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public HomeBannerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public void onTitleSlect(TextView tv, int position) {

    }

    @Override
    public View onCreateItemView(int position) {
        View view = View.inflate(mContext, R.layout.home_banner_item, null);
        ImageView iv = (ImageView) view.findViewById(R.id.imageView);

        Banner item = getItem(position);
        if (item == null) {
            return view;
        }
        iv.setTag(item);

        Glide.with(App.getInstance()).load(item.resId).apply(GlideUtil.getAvatarPlaceholder()).into(iv);
        return view;
    }
}
